package cn.seecoder.ai.config;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.spark.sql.SparkSession;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author fanyanpeng
 * @date 2023/4/7 4:06
 */
@Data //需要支持变量访问
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "spark")
public class SparkConfig {

    private String appName;

    private String   executorMemory;

    private String master;

    @Bean
    public SparkSession sparkSession() {
        SparkSession sparkSession = SparkSession.builder()
                .appName(appName)
                .master(master)
                .getOrCreate();
        log.info("SparkSession创建成功: " + sparkSession);
        return sparkSession;

    }

}
